package meta.api.web.directory.businesscontrol;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import meta.api.web.common.business.BusiCmnService;
import meta.api.web.directory.businessinfo.DirInfo;

@Transactional
@Component
public class DirMngBusiCtrl {

    @Autowired
    private BusiCmnService busiCmnService;

    @Transactional(readOnly = true)
    public int getDirTotal(String userId, String type, String fullpath) {
        return busiCmnService.getDirInfoTotal(userId, type, fullpath);
    }

    @Transactional(readOnly = true)
    public List<DirInfo> getDirList(String userId, String type, String fullpath) {
        return busiCmnService.getDirInfoList(userId, type, fullpath);
    }

    @Transactional(readOnly = true)
    public boolean checkExistDir(String userId, String type, String fullpath) {
        return busiCmnService.checkExistDir(userId, type, fullpath);
    }

    @Transactional(rollbackFor = Exception.class)
    public void saveDir(String userId, String type, String fullpath) {
        busiCmnService.addDirInfo(userId, type, fullpath);
    }

    @Transactional(readOnly = true)
    public DirInfo getDir(String userId, String type, String fullpath) {
        return busiCmnService.getDirInfo(userId, type, fullpath);
    }

    @Transactional(rollbackFor = Exception.class)
    public void updateDir(String userId, String type, String oldFullpath, String newFullpath) {
        busiCmnService.updateDirInfo(userId, type, oldFullpath, newFullpath);
    }

    @Transactional(rollbackFor = Exception.class)
    public void deleteDir(String userId, String type, List<String> fullpaths) {
        busiCmnService.deleteDirInfo(userId, type, fullpaths);
    }
}
